package com.cn.controller.dz;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.cn.controller.BaseServlet;
import com.cn.service.MendianContrl;

@WebServlet("/getmendian")
public class Getmendian extends BaseServlet {
	private MendianContrl mc;
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		mc = new MendianContrl();
		String address = req.getParameter("city");
		List<Map<String, String>> list = mc.getMendian(address);
		if(getMendian(list)!=""){
			resp.getWriter().println(getMendian(list));
		}else{
			resp.getWriter().println(-1);
		}
		
	}
	
	public String getMendian(List<Map<String, String>> list){
		String html = ""; 
		for(Map<String, String> i:list){
			
			html +="<option value='"+i.get("id")+"'>"+i.get("name")+"</option>";
		}
		return html;
	}
}
